package day16.ZiXi.UDP;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket();

        Scanner sc = new Scanner(System.in);
        while (true){
            String s = sc.nextLine();
            //输入的数据是886，发送数据结束
            if ("886".equals(s)){
                break;
            }
            //创建数据，并把数据打包
            byte[] bys = s.getBytes();
            DatagramPacket dp = new DatagramPacket(bys, bys.length, InetAddress.getByName("127.0.0.1"), 123456);
            ds.send(dp);
        }
        ds.close();

    }

}
